//
//  YYEWrongRecordViewController.m
//  YuYingEDU
//
//  Created by 胡波 on 2018/1/5.
//  Copyright © 2018年 胡波. All rights reserved.
//

#import "YYETopicRecordViewController.h"
#import "YYETopicRecordTableViewCell1.h"

@interface YYETopicRecordViewController () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong) YYEBaseTableView *tableView;
@property (nonatomic,strong) NSArray *datas;

@end

@implementation YYETopicRecordViewController

static NSString * recordCell = @"recordCell";
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self configUI];
    
    [self getHistoryList];
    
    
}

- (void)getHistoryList {
    
    NSDictionary *dic = @{
                          //                          @"cid":self.cid,
                          //                          @"p":@(self.page),
                          //                          @"size":@10,
                          @"uid":[LoginModel shareLogin].uid,
                          @"username":[LoginModel shareLogin].username,
                          @"token":[LoginModel shareLogin].token
                          };
    [SVProgressHUD show];
    [AFNHelper post:HistoryList parameters:dic success:^(id responseObject) {
        
        
        if ([responseObject[@"status"] isEqual:@1]) {
            
            NSArray *commandArr = [YYEWrongRecordModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"]];
            self.datas = commandArr;
            [self.tableView reloadData];
        }
//        [SVProgressHUD showWithStatus:responseObject[@"message"]];
        [SVProgressHUD dismiss];
        
    } faliure:^(id error) {
        
        NSLog(@"请求失败");
        [SVProgressHUD showWithStatus:ShowError];
        [SVProgressHUD dismissWithDelay:0.5];
        
    }];
    
}

- (void)configUI {
    
    [self.view addSubview:self.tableView];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.tableView registerClass:[YYETopicRecordTableViewCell1 class] forCellReuseIdentifier:recordCell];
    
    [self.tableView makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(UIEdgeInsetsZero);
    }];
    
}

- (YYEBaseTableView *)tableView {
    
    if (!_tableView) {
        _tableView = [[YYEBaseTableView alloc]initwithDelegate:self];
    }
    return _tableView;
    
}

#pragma mark -- UITableView;
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.datas.count;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    YYETopicRecordTableViewCell1 *cell = [tableView dequeueReusableCellWithIdentifier:recordCell];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.model = self.datas[indexPath.row];
    
    return cell;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 82;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end

